package models;

import helpers.IdUniqueHelper;
import helpers.StringHelper;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.Unique;
import javax.persistence.Id;

import com.googlecode.objectify.annotation.Cached;
import com.googlecode.objectify.annotation.Indexed;
import com.googlecode.objectify.annotation.Unindexed;

@Cached
public class NewsModel implements Serializable {
	@Id private String id = ""; //id = autoSite + url
	
	@Indexed private String url = "";
	
	@Indexed private String autoSite = "";
	
	@Unindexed private String title = "";
	
	@Unindexed private String description = "";
	
	@Unindexed private String content = "";
	
	@Indexed private boolean published = false;
	
	@Unindexed private boolean displaySource = true;
	
	@Indexed private Date created = new Date();
	
	@Indexed private String creator = "";
	
	@Unindexed private String category = "";
	
	@Indexed private boolean hotNews = false;
	
	@Unindexed private String alias = "";
	
	public String getId() {
		return id;
	}

	public void setId() {
		this.id = IdUniqueHelper.getId();
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getAutoSite() {
		return autoSite;
	}

	public void setAutoSite(String autoSite) {
		this.autoSite = autoSite;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public boolean isPublished() {
		return published;
	}

	public void setPublished(boolean published) {
		this.published = published;
	}

	public boolean isDisplaySource() {
		return displaySource;
	}

	public void setDisplaySource(boolean displaySource) {
		this.displaySource = displaySource;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public boolean isHotNews() {
		return hotNews;
	}

	public void setHotNews(boolean hotNews) {
		this.hotNews = hotNews;
	}

	public String getAlias() {
		return alias;
	}

	public void setAlias() {
		this.alias = StringHelper.getAlias(getTitle());
	}
	
}
